class Solution(object):
    def singleNumber(self, nums):
        once_set = set()
        twice_set = set()
        for i in nums:
            if i in once_set:
                once_set.remove(i)
                twice_set.add(i)
            elif i in twice_set:
                pass
            else:
                once_set.add(i)
        return once_set.pop()

if __name__ == '__main__':
    s = Solution()
    r = s.singleNumber([1, 1, 2, 2, 3, 4, 4])
    print(r)
